import requestProxy from '@/utils/request';

const { request } = requestProxy;

// 封账列表
export function getList(page, perPage, params) {
  return request({
    url: '/admin/sealBill/list',
    method: 'get',
    params: {
      page,
      perPage,
      ...params
    }
  });
}

// 提交封账
export function submitSeal(id) {
  return request({
    url: `/admin/sealBill/submitSeal/${id}`,
    method: 'post'
  });
}

// 提交封账判断待封账订单
export function notSealList(id) {
  return request({
    url: `admin/sealBill/submitSeal/notSealingList/${id}`,
    method: 'get'
  });
}

// 初审确认
export function isAudit(data) {
  return request({
    url: '/admin/review/market/confirm',
    method: 'put',
    data
  });
}

// 单条审批不通过
export function financeFail(id, remark) {
  return request({
    url: `/admin/review/finance/${id}/fail`,
    method: 'put',
    data: {
      remark
    }
  });
}

// 单条审批通过
export function financePass(id) {
  return request({
    url: `/admin/review/finance/${id}/pass`,
    method: 'put'
  });
}

// 审批详情
export function reviewDetail(params) {
  return request({
    url: `/admin/review/${params.id}/detail`,
    method: 'get',
    params
  });
}

// 封账
export function sealBill(id) {
  return request({
    url: '/admin/sealBill/pass',
    method: 'put',
    data: {
      id
    }
  });
}

// 总财务复审通过
export function allReviewPass(params) {
  return request({
    url: '/admin/review/batchReview/pass',
    method: 'put',
    data: params
  });
}
export function allReviewFail(params) {
  return request({
    url: '/admin/review/batchReview/fail',
    method: 'put',
    data: params
  });
}

// 返回销售初审
export function backSealingAudit(id) {
  return request({
    url: `/admin/sealBill/${id}/finance/fail`,
    method: 'put'
  });
}

// 撤销审批
export function sealBillBackout(data) {
  return request({
    url: `/admin/review/${data.id}/backout`,
    method: 'put',
    data
  });
}

// 判断金额是否一致
export function sealBillAmount(params) {
  return request({
    url: '/admin/sealBill/amount',
    method: 'get',
    params
  });
}

// 返回提交封账
export function sealBillBack(id) {
  return request({
    url: `/admin/sealBill/${id}/back`,
    method: 'put'
  });
}

// 封账订单列表
export function getSealOrderList(params, id) {
  if (!params.page) params.page = 1;
  return request({
    url: `/admin/review/${id}/orderList`,
    method: 'get',
    params
  });
}

// 封账流水列表
export function getSealPipelineList(params, id) {
  return request({
    url: `/admin/review/${id}/pipelineList`,
    method: 'get',
    params
  });
}

// 封账流水列表
export function getSealVerificationList(params, id) {
  return request({
    url: `/admin/review/${id}/verificationList`,
    method: 'get',
    params
  });
}

// 取消封账
export function cancelSealing(id) {
  return request({
    url: `admin/sealBill/cancel/${id}`,
    method: 'post'
  });
}

// 刷新封账时间
export function sealBillRefresh(id) {
  return request({
    url: `/admin/sealBill/refresh/${id}`,
    method: 'post'
  });
}

// 封账数据
export function seallBilData(id) {
  return request({
    url: `/admin/sealBill/data/${id}`,
    method: 'get'
  });
}

// 退回财务复审
export function backRecheck(id) {
  return request({
    url: `admin/sealBill/sealingAccount/back/${id}`,
    method: 'put'
  });
}

export function cancelOrder(data) {
  return request({
    url: `admin/review/orderList/cancel/${data.sealingId}`,
    method: 'post',
    data
  });
}
export function cancelPipeline(data) {
  return request({
    url: `admin/review/pipelineList/cancel/${data.sealingId}`,
    method: 'post',
    data
  });
}
export function cancelVerification(data) {
  return request({
    url: `admin/review/verificationList/cancel/${data.sealingId}`,
    method: 'post',
    data
  });
}

export function storeBatchSeal(data) {
  return request({
    url: 'admin/sealBill/batchSeal/store',
    method: 'post',
    data
  });
}

// 封账列表统计面板
export function getSealBillStatistics(params) {
  return request({
    url: 'admin/sealBill/list/statistics',
    method: 'get',
    params
  });
}

// 封账成本列表
export function getSealCostList(params, id) {
  return request({
    url: `/admin/review/${id}/costList`,
    method: 'get',
    params
  });
}

// 成本取消参与封账
export function cancelCost(data) {
  return request({
    url: `admin/review/cost/cancel/${data.sealingId}`,
    method: 'post',
    data
  });
}

